package masterjava.reporting.shared.entity;

import masterjava.common.shared.charts.IntradaysEntry;
import masterjava.common.shared.entity.BaseEntity;

import javax.persistence.*;
import java.util.Date;

/**
 * User: Grigory Kislin
 * Date: 23/06/11
 */
@Entity

@NamedQueries({
        @NamedQuery(
                name = TimestampData.FIND_BY_DATA_ID,
                query = "from TimestampData td where td.dataId=:" + TimestampData.DATA_ID+" order by timestamp"
        )
})
@Table(name = "TIMESTAMP_DATA")
@Access(AccessType.PROPERTY)
public class TimestampData extends BaseEntity implements IntradaysEntry {

    private Date timestamp;
    private Double volume;
    private Double value;
    private Long dataId;

    public static final String FIND_BY_DATA_ID = "FIND_BY_DATA_ID";
    public static final String DATA_ID = "dataId";

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "TIMESTAMP")
    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    @Column(name = "VALUE")
    public Double getValue() {
        return value;
    }

    public void setValue(Double value) {
        this.value = value;
    }

    @Column(name = "DATA_ID")
    public Long getDataId() {
        return dataId;
    }

    public void setDataId(Long dataId) {
        this.dataId = dataId;
    }

    @Column(name = "VOLUME")
    public Double getVolume() {
        return volume;
    }

    public void setVolume(Double volume) {
        this.volume = volume;
    }

    @Override
    public void prepareToSerialize() {
    }
}
